package com.sysadmin.vo;

import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;

import com.common.util.StringUtil;

public class JtreeVO {
	
	private String id;
	private String name;
	private String url;
	private List<JtreeVO> children= new ArrayList<JtreeVO>();
	private String iconSkin;
	private boolean open=false;
	
	private String target;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getIconSkin() {
		return iconSkin;
	}
	public void setIconSkin(String iconSkin) {
		this.iconSkin = iconSkin;
	}
	
	public boolean isOpen() {
		return open;
	}
	public void setOpen(boolean open) {
		this.open = open;
	}
	public String getTarget() {
		return target;
	}
	public void setTarget(String target) {
		this.target = target;
	}
	
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	public List<JtreeVO> getChildren() {
		return children;
	}
	public void setChildren(List<JtreeVO> children) {
		this.children = children;
	}
	
	public String toJsonString(){
		JsonConfig jsonConfig = new JsonConfig();  
		jsonConfig.setJsonPropertyFilter( new PropertyFilter(){  
		public boolean apply(Object source/* 属性的拥有者 */, String name /*属性名字*/, Object value/* 属性值 */ ){  
		          // return true to skip name  
			if(StringUtil.isBlank(value)){
				return true;
			}
			if (value instanceof java.util.ArrayList) {
				ArrayList l = (ArrayList) value;
				if(l.size()==0){
					return true;
				}
			}
		    return false;  
		}  
		});  

		 JSONArray jsonObject =  JSONArray.fromObject(this,jsonConfig);
		 return jsonObject.toString();
	}
}
